#ifndef HEXEDITVIEWBASE_H
#define HEXEDITVIEWBASE_H

#include "FileContentBase.h"
#include "HexEditLineBuffer.h"

class HexEditPanel;



class HexEditViewBase {
  public:

    typedef FileContentBase::OffsetT OffsetT;


    HexEditViewBase( HexEditPanel* panel );


    virtual ~HexEditViewBase();


    bool SetActive( bool makeMeActive = true );


    bool GetActive() { return m_IsActive; }


    void CalculateBlockSize(
      OffsetT  screenStartOffset,
      OffsetT  currentOffset,
      OffsetT& blockStart,
      OffsetT& blockEnd );


    void JumpToOffset(
      OffsetT screenStartOffset,
      OffsetT currentOffset,
      OffsetT blockStart,
      OffsetT blockEnd,
      int     positionFlags );


    OffsetT GetScreenStartOffset() { return m_ScreenStartOffset; }


    OffsetT GetCurrentOffset() { return m_CurrentOffset; }


    int GetCurrentPositionFlags() { return OnGetCurrentPositionFlags(); }


    OffsetT GetBlockStartOffset() { return m_BlockStartOffset; }


    OffsetT GetBlockEndOffset() { return m_BlockEndOffset; }


    void PutChar( wxChar ch );


    void MoveLeft();


    void MoveRight();


    void MoveUp();


    void MoveDown();


    void PutLine( OffsetT lineStartOffset, HexEditLineBuffer& buffer, char* content, int bytes );


    void GetBlockSizes( int& blockLength, int& blockBytes, int& spacing );


    int GetOffsetFromColumn( int column, int& positionFlags );

  protected:


    virtual void OnActivate( bool becomesActive ) = 0;


    virtual void OnCalculateBlockSize( OffsetT& blockStart, OffsetT& blockEnd );


    virtual void OnOffsetChange( int positionFlags );


    virtual int OnGetCurrentPositionFlags();


    virtual void OnProcessChar( wxChar ) = 0;


    virtual void OnMoveLeft() = 0;


    virtual void OnMoveRight() = 0;


    virtual void OnMoveUp() = 0;


    virtual void OnMoveDown() = 0;


    virtual void OnPutLine( OffsetT startOffset, HexEditLineBuffer& buff, char* content, int bytes ) = 0;


    virtual void OnGetBlockSizes( int& blockLength, int& blockBytes, int& spacing ) = 0;


    virtual int OnGetOffsetFromColumn( int column, int& positionFlags ) = 0;



    FileContentBase* GetContent();


    unsigned int GetLineBytes();


    void OffsetChange( OffsetT currentOffset );


    void ContentChange();


  private:

    bool    m_IsActive;             ///< \brief Set to true if this view is active (has keyboard focus)
    OffsetT m_ScreenStartOffset;    ///< \brief Offset of first data byte shown on the screen
    OffsetT m_CurrentOffset;        ///< \brief Offset of current byte
    OffsetT m_BlockStartOffset;     ///< \brief Start offset of current data block
    OffsetT m_BlockEndOffset;       ///< \brief End offset of current data block
    HexEditPanel* m_Panel;
};

#endif
